<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../jquery.js"></script>
    <link rel="stylesheet" href="../bootstrap-3.4.1/dist/css/bootstrap.css">
    <script src="../bootstrap-3.4.1/dist/js/bootstrap.js"></script>
</head>
<style>
    .hengjia,
    .leijia {
        background-color: #428BCA;
        border: none;
        color: white;
    }

    .hdiyige,
    .hdierge,
    .hdisange,
    .ldiyige,
    .ldierge,
    .ldisange {
        background-color: #D9534F;
        border: none;
        color: white;
    }

    tr,
    th,
    td {
        text-align: center;
    }

    .shan {
        background-color: #D9534F;
        border: none;
        color: white;
    }
</style>

<body>
    <table class="table table-striped table-bordered table-hover table-condensed" style="width: 800px;margin: auto;">
        <thead>
            <tr>
                <th></th>
                <th>参数值<button class="hang">-</button></th>
                <th>参数值<button class="hang">-</button></th>
                <th>参数值<button class="hang">-</button></th>
                <th><button class="hengjia">+</button></th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>参数名</td>
                <td><input type="text" value="" name="zhi" class="yi"></td>
                <td><input type="text" value="" name="zhi" class="er"></td>
                <td><input type="text" value="" name="zhi" class="san"></td>
                <td></td>
            </tr>
            <tr>
                <td>参数名</td>
                <td><input type="text" value="" name="zhi" class="yi"></td>
                <td><input type="text" value="" name="zhi" class="er"></td>
                <td><input type="text" value="" name="zhi" class="san"></td>
                <td><button class="shan">-</button></td>
            </tr>
            <tr>
                <td>参数名</td>
                <td><input type="text" value="" name="zhi" class="yi"></td>
                <td><input type="text" value="" name="zhi" class="er"></td>
                <td><input type="text" value="" name="zhi" class="san"></td>
                <td><button class="shan">-</button></td>
            </tr>
            <tr>
                <td>参数名</td>
                <td><input type="text" value="" name="zhi" class="yi"></td>
                <td><input type="text" value="" name="zhi" class="er"></td>
                <td><input type="text" value="" name="zhi" class="san"></td>
                <td><button class="shan">-</button></td>
            </tr>
        <tbody class="tb"></tbody>
        <tr>
            <td><button class="leijia">+</button></td>
        </tr>
        </tbody>
    </table>
    <button class="save">保存</button>
</body>
<script>
    var arr = []
    $(function () {
        hangObj()
        leiObj()
    })
    // 行加
    function hangObj() {
        $('.leijia').click(function () {
            var strheng = ''

            strheng += `<tr>
                        <td>参数名</td>
                        <td><input type="text" value="" name="zhi"></td>
                        <td><input type="text" value="" name="zhi"></td>
                        <td><input type="text" value="" name="zhi"></td>
                        <td><button class="shan">-</button></td>
                    </tr>`

            $('.tb').append(strheng)
            // 删除
            $('.shan').click(function () {
                $(this).parent().parent().remove()
            })
            // $('input[name="zhi"]').blur(function () {
            //     console.log(666);
            //     localStorage.getItem('strheng')
            // })
        })
    }

    function leiObj() {
        $('.hengjia').click(function () {
            var strshu = ''

            strshu += `<tr>
                            <td>参数名</td>
                            <td><input type="text" value="" name="zhi"></td>
                            <td><input type="text" value="" name="zhi"></td>
                            <td><input type="text" value="" name="zhi"></td>
                            <td><button class="shan">-</button></td>
                        </tr>`

            $('tbody').after(strshu)

            $('.shan').click(function () {
                $(this).parent().parent().remove()
            })
        })
    }

    $('.hang').click(function () {
        // $(this).remove() 
        var del = $('tr td input[name]').first().remove()
        
    })

    $('#save').click(function(){
        arr.localStorage.getItem('strheng')
    })
</script>

</html>